#@layout()

#define js()
    <script>
    $(function(){
        var _table;
        _table =$("#task-list").DataTable( {
            aLengthMenu:[10,20,50],
            "processing": true,
            "serverSide": true,
            "bLengthChange": false,
            "bSort":false,
            "bStateSave":true,
            searching: false,//屏蔽datatales的查询框
            "pagingType":   "full_numbers",
            "ajax":{
                "url": "/admin/task/listAll",
                "type": "post",
                "data": function (params) {
                        params["task.task_title"]=$("#task_title").val();
                        params["task.task_start_time"]=$("#task_start_time").val();
                        params["task.task_end_time"]=$("#task_end_time").val();
                }
            },
            "columns": [
                    { "data": "id" },
                    { "data": "task_title" },
                    { "data": "task_start_time" },
                    { "data": "task_end_time" },
                    { "data": "task_price" },
//                    { "data": "status" },
                    {"data": function (data) {
                        var opt="<a href='javascript:;' onclick='showStatus("+data.id+")'>"+data.status+"</a>";
                        return opt;
                    }},
                    { "data": "extension_type" },
                    { "data": "wh_number" },
                { "data": function(data){
                    var opt="<a href='javascript:;' onclick='del("+data.id+")'>删除</a>|";
                    if(data.status=='审核中'){
                    	opt+="<a href='javascript:;' onclick='pass("+data.id+")'>审核通过</a>|";
                    	opt+="<a href='javascript:;' onclick='refuse("+data.id+")'>审核不通过</a>|";
                    }else{
                    	opt+="<a href='javascript:;' onclick='log("+data.id+")'>操作日志</a>|";
                    	opt+="<a href='javascript:;' onclick='showdetail("+data.id+")'>查看详情</a>|";
                        opt+="<a href='javascript:;' onclick='process("+data.id+")'>进度</a>|";
                    }
                    return opt;
                }
               }
            ]
        } );
        $("#searchBtn").click(function(){
            _table.ajax.reload();
        });
});


    /*编辑*/
    function edit(id){
        var title="编辑";
        var url="#(contextPath)/admin/task/queryById?id="+id;
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }
    
    /*进度*/
    function process(id){
        var title="任务进度";
        var url="#(contextPath)/admin/task/queryProcessById?id="+id;
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }
    
    /*添加*/
    function add(){
        var title="添加";
        var url="#(contextPath)/admin/task/add/";
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }

    /*删除*/
    function del(id){
        var config = {
        "url":"#(contextPath)/admin/task/deleteById?id="+id,
        data:{}
        };
        var backendTool = new BackendTool(config);
        backendTool.ajaxRequest();
    }
    
    /*操作日志*/
    function log(id){
        var title="操作日志";
        var url="#(contextPath)/admin/opertion/queryLog?id="+id+"&taskType=2";
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }
    
    
    /*查看详情*/
    function showdetail(id){
        var title="查看详情";
        var url="#(contextPath)/admin/task/showDetail?id="+id;
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }

    
    /*审核通过*/
    function pass(id){
        var config = {
        "url":"#(contextPath)/admin/task/pass?id="+id,
        data:{}
        };
        var backendTool = new BackendTool(config);
        backendTool.ajaxRequest();
    }
    
    /*拒绝对话框*/
    function refuse(id){
        var title="操作日志";
        var url="#(contextPath)/admin/task/toRefuse?id="+id;
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }

    /*修改任务状态*/
    function showStatus(id){
        var title="修改任务状态";
        var url="#(contextPath)/admin/task/showStatus?id="+id;
        var w="";
        var h=510;
        layer_show(title,url,w,h);
    }

    </script>
#end

#define main()
    #@breadcrumb(["运营管理","任务列表"])
   <div class="page-container">
       <div class="text-c">
           <input type="text" name="task.task_title" id="task_title" placeholder="请输入任务标题进行检索..." style="width:350px" class="input-text">
           <button name="" id="searchBtn" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>检索</button>
       </div>
       #--
       <div class="cl pd-5 bg-1 bk-gray mt-20">
		    <span class="l">
		        <a href="javascript:;" onclick="add()" class="btn btn-primary radius">添加</a>
		    </span>
           <span class="r">
       </div>
       --#
       <div class="mt-20">
           <table class="table table-border table-bordered table-bg table-hover table-sort" id="task-list">
               <thead>
               <tr class="text-c">
                     <th>id</th>
                     <th>任务标题</th>
                     <th>任务开始时间</th>
                     <th>任务结束时间</th>
                     <th>任务预算</th>
                     <th>任务状态</th>
                     <th>推广方式</th>
                     <th>主播人数</th>
                   <th>操作</th>
               </tr>
               </thead>
               <tbody>
               </tbody>
           </table>
       </div>
   </div>
#end